package com.mask.sca.system.controller;

import com.mask.sca.system.entity.Tenant;
import com.mask.sca.system.service.TenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/tenant")
public class TenantController {
    @Autowired
    private TenantService tenantService;

    @GetMapping("/list")
    public List<Tenant> list() {
        return tenantService.list();
    }

    @GetMapping("/{id}")
    public Tenant get(@PathVariable Long id) {
        return tenantService.getById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Tenant tenant) {
        return tenantService.save(tenant);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Tenant tenant) {
        return tenantService.updateById(tenant);
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Long id) {
        return tenantService.removeById(id);
    }
} 